import Mock from 'mockjs'

const baseURL = "http://localhost:8081" ;
//------建立mock测试-------------
Mock.mock(baseURL + '/mock/test','post',(res:any) => {
    let a:any = JSON.parse(res.body);
    a.mock = '我是mock测试';
    const b =a ;
    return b ;
});

//-------用户登录---------------
import {vip_login,admin_login} from "./moData/loginData"
Mock.mock(baseURL + '/mock/login','post',(res:any) => {
    let user:any = JSON.parse(res.body);
    let userData:any ;
    if(user.name == 'admin'){
        userData = admin_login ;
    }else {
        userData = vip_login ;
    }
    return userData ;
});

Mock.mock(baseURL + '/mock/getMenu','post',(res:any) => {
    let user:any = JSON.parse(res.body);
    let userData:any ;
    if(user.token == 'admin'){
        userData = admin_login ;
    }else {
        userData = vip_login ;
    }
    return userData ;
});

//-------导出Mock,在Main.ts 中引用-------
//export default Mock ;